home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_319
/
cnewssrc
/
cnews.orig.lzh
/
expire
/
upact
< prev
Wrap
Text File
|
1989-06-27
|
1KB
|
61 lines
#! /bin/sh
# Update 3rd field (minimum art. #) of a 4-field active file.
# =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
. ${NEWSCONFIG-/usr/lib/news/bin/config}
PATH=$NEWSCTL/bin:$NEWSBIN/expire:$NEWSBIN:$NEWSPATH ; export PATH
umask $NEWSUMASK
cd $NEWSCTL || { echo "$0: can't cd to $NEWSCTL" >&2; exit 1; }
# check active file format
set ""`sed 1q active`
case $# in
4) ;;
*) echo "$0: active file has other than 4 fields" >&2
exit 1 ;;
esac
# lock news system
lock="$NEWSCTL/LOCK"
ltemp="$NEWSCTL/L.$$"
echo $$ >$ltemp
trap "rm -f $ltemp ; exit 0" 0 1 2 15
while true
do
if newslock $ltemp $lock
then
trap "rm -f $ltemp $lock ; exit 0" 0 1 2 15
break
fi
sleep 30
done
while read group max min fourth
do
dir=`echo $group | tr . / ` # map ng name to directory name
min=
if test -d $NEWSARTS/$dir
then
# min=`lowest $NEWSARTS/$dir`
min=`ls $NEWSARTS/$dir | egrep '^[0-9]+$' | sort -nr | tail -1`
fi
case "$min" in # no files, so
"") min=$max ;; # use maximum
esac
case "$min" in
[0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]) # short
min=`expr 00000$min : '.*\(.....\)$'` ;;
esac
echo $group $max $min $fourth
done <active >active.new
# replace active, carefully
rm -f active.old
ln active active.old
mv active.new active
exit 0